import {BaseGameEntity as Entity} from "../game/BaseGameEntity";
import {Singleton} from "../misc/Singleton";
import {Telegram} from "../message/Telegram";

export interface IState<T> {
    //this will execute when the state is entered
    enter(entity:T) : void;

    //this is the state's normal update function
    execute(entity:T) : void;  

    //this will execute when the state is exited. (My word, isn't
    //life full of surprises... ;o))
    exit(entity:T) : void;
}


export abstract class State<T extends Entity> extends Singleton implements IState<T>{
    //this will execute when the state is entered
    abstract enter(entity:T) : void;

    //this is the state's normal update function
    abstract execute(entity:T) : void;  

    //this will execute when the state is exited. 
    abstract exit(entity:T) : void;

    //this executes if the agent receives a message from the 
    //message dispatcher
    abstract onMessage(entity:T, t:Telegram);
}
